package com.itboye.ihomebank.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.Button;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.custom.FlowLayout;
import com.itboye.ihomebank.util.ByAlert;
/**
 * 合同4
 *
 */
public class ActivityTianXieHeTongFour extends BaseOtherActivity {

	Button yulan, next;
	FlowLayout flowLayout;
	/**点击标签的次数*/
	private int dian=1;
	
	String[] biao= {"电视机","冰箱","煤气炉","空调","电脑","写字桌","双人床"};

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent = null;
		switch (v.getId()) {
		case R.id.yulan:

			// intent=new Intent(this,.class);
			// startActivity(intent);
			break;
		case R.id.next:
			// intent=new Intent(this,.class);
			startActivity(intent);
			break;
		default:
			break;
		}
	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_tianxiehetong_three;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		for (int i = 0; i < biao.length; i++) {
			View view = LayoutInflater.from(this).inflate(R.layout.item_jiaju,
					null);
			final TextView num = (TextView) view.findViewById(R.id.num);
			final TextView btn_name = (TextView) view.findViewById(R.id.btn_name);
			
			btn_name.setText(biao[i]);
			
			btn_name.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					ByAlert.alert("点击的按钮");
					
					dian++;
					if(dian%2==0){
						btn_name.setBackgroundResource(R.drawable.shape_blue02);
						num.setVisibility(View.VISIBLE);
					}else{
						btn_name.setBackgroundResource(R.drawable.shape_gray);
						num.setVisibility(View.GONE);
						num.setText(1+"");
					}
					
				}
			});
			num.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					ByAlert.alert("点击的数字");
					num.setText((Integer.parseInt(num.getText().toString()) + 1)+"");
				}
			});
			MarginLayoutParams layoutParams = new MarginLayoutParams(
					MarginLayoutParams.WRAP_CONTENT,
					MarginLayoutParams.WRAP_CONTENT);
			layoutParams.setMargins(10, 10, 10, 10);
			flowLayout.addView(view, layoutParams);
		}
	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

}
